import 'package:flutter/material.dart';
import 'package:full_display/common/qxp_color.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/generated/l10n.dart';
import 'package:full_display/provide/time_provider.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:full_display/unit/widgets/widget_dialog/add_clock_dialog.dart';
import 'package:provider/provider.dart';

class ClockDialog extends Dialog {
  final String time;
  final String week;
  ClockDialog({this.time = '', this.week = ''});
  late TimeProvider _TimeData;
  @override
  Widget build(BuildContext context) {
    _TimeData = context.watch<TimeProvider>();
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          width: 320.0.W,
          height: 232.0.W,
          decoration: const BoxDecoration(
            gradient: LinearGradient(
                //渐变位置
                begin: Alignment.topCenter, //右上
                end: Alignment.bottomCenter, //左下
                //渐变颜色[始点颜色, 结束颜色]
                colors: [ColorPlate.app_blue, ColorPlate.sub_blue]),
            borderRadius: BorderRadius.all(Radius.circular(8.0)),
          ),
          child: Container(
            child: Column(
              children: [
                Container(
                  padding: EdgeInsets.only(left: 12.0.W, right: 12.0.W),
                  child: Column(
                    children: [
                      Container(
                        padding: EdgeInsets.only(top: 20.0.W),
                        child: Text(S.of(context).timing,
                            style: StandardTextStyle.textWhite17BoldStyle),
                      ),
                      Container(
                        padding: EdgeInsets.only(top: 20.0.W, bottom: 20.0.W),
                        child: _TimeData.listTime.isNotEmpty
                            ? Text(
                                '${_TimeData.listTime[0]} - ${_TimeData.listTime[1]}',
                                maxLines: 1,
                                textAlign: TextAlign.left,
                                style: StandardTextStyle
                                    .textWhite24BoldEllipsisStyle)
                            : const Text(''),
                      ),
                      Container(
                        padding: EdgeInsets.only(bottom: 20.0.W),
                        child: _TimeData.getWeek().isNotEmpty
                            ? Text(_TimeData.getWeek(),
                                maxLines: 1,
                                textAlign: TextAlign.left,
                                style: StandardTextStyle.textWhite14BoldStyle)
                            : const Text(''),
                      ),
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(top: 20.0.W),
                  child: Divider(
                    height: 1.0.W,
                    color: ColorPlate.white, // 分割线颜色
                  ),
                ),
                Expanded(
                  child: InkWell(
                    onTap: () {
                      Navigator.pop(context);
                      showDialog(
                        context: context,
                        barrierDismissible: true,
                        builder: (context) {
                          return AddClockDialog();
                        },
                      );
                    },
                    child: Center(
                      child: Text(S.of(context).Add_timing,
                          style: StandardTextStyle.textWhite17BoldStyle),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
